{% extends "base.html" %}

{% block title %}日志管理 - 在线跑批系统{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1>日志管理</h1>
</div>

<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover table-striped">
                <thead class="table-light">
                    <tr>
                        <th>任务名称</th>
                        <th>服务器</th>
                        <th>状态</th>
                        <th>开始时间</th>
                        <th>执行人</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for log in logs %}
                        <tr>
                            <td>{{ log.task.name }}</td>
                            <td>{{ log.task.server.name }}</td>
                            <td>
                                {% if log.status == 'running' %}
                                    <span class="badge bg-warning">运行中</span>
                                {% elif log.status == 'completed' %}
                                    <span class="badge bg-success">已完成</span>
                                {% elif log.status == 'failed' %}
                                    <span class="badge bg-danger">已失败</span>
                                {% endif %}
                            </td>
                            <td>{{ log.started_at|date:"Y-m-d H:i:s" }}</td>
                            <td>{{ log.started_by.username }}</td>
                            <td>
                                <a href="{% url 'log_detail' log.id %}" class="btn btn-sm btn-outline-info">
                                    <i class="fas fa-eye"></i> 查看详情
                                </a>
                            </td>
                        </tr>
                    {% empty %}
                        <tr>
                            <td colspan="6" class="text-center text-muted py-3">
                                <p>暂无日志数据</p>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
